app.controller('SelectMenuCtrl', function ($scope, $location) {
    function disable()
    {
        if( $scope.person == null && $scope.restaurant == null && $scope.combo_name == '') {
            document.getElementById("disabled").disabled = true;
        }
    }
    disable();
    $scope.go_to_look_order = function () {

        $location.path('')
    }

    $scope.go_to_select_people = function () {

        $location.path('select_people')
    }


    $scope.go_to_select_restaurant = function () {

        $location.path('select_restaurant')
    }


    $scope.go_to_select_combo = function () {


        $location.path('select_combo')
    }
    $scope.person = localStorage.getItem('person');
    $scope.restaurant = localStorage.getItem('restaurant');
    $scope.name = localStorage.getItem('combo_name');

    $scope.go_to_commit_menu = function () {
        var person_order = {};

        person_order.person = localStorage.getItem ('person');

        person_order.restaurant = localStorage.getItem ('restaurant');

        person_order.combo_name = localStorage.getItem ('combo_name');

        person_order.combo_price = localStorage.getItem ('combo_price');
        if(JSON.parse(localStorage.getItem('informs')) == null){
            var all_informs = [];
        }
        else {
            var all_informs = JSON.parse(localStorage.getItem('informs'));
        }
        all_informs.push(person_order);
        var informs = JSON.stringify(all_informs);
        localStorage.setItem('informs',informs);
        clean($scope)
    }
})

function clean($scope) {
   localStorage.removeItem('person');
    localStorage.removeItem('restaurant');
    localStorage.removeItem('combo_name');
    localStorage.removeItem('combo_price');
    $scope.person = '';
    $scope.restaurant = '';
    $scope.name = '';
}

function changeDisabled()
{
    var name = document.getElementByIdx_x("name");
    if(name.disabled == true)
    {
        name.disabled = false;
    }
    else
    {
        name.disabled = true;
    }
}